package com.wsg.dep.queue;

/**
 * @className: Test2
 * @author: 承泽
 * @date: 2025/3/18 19:45
 * @description:
 */
public class Test2 {
    public static long total = 10000 * 10000;
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(1000);
        new Thread(() -> {
            add(Long.MAX_VALUE,"Long.MAX_VALUE");

        }, "Long.MAX_VALUE").start();

        new Thread(() -> {
            countMax(Long.MAX_VALUE, "128");

        }, "128").start();
    }

    public static void add(long max, String name) {
        long s = System.currentTimeMillis();
        for (long i = max - total; i < Long.MAX_VALUE; i++) {
            i++;
        }
        System.out.println(name + " 用时：" + (System.currentTimeMillis() - s));
    }

    public static void countMax(long max,String name) {
        long s = System.currentTimeMillis();
        int count = 0;
        for (int i = 0; i < total; i++) {
            if (count == max) {
                count = 0;
            } else {
                count++;
            }
        }
        System.out.println(name + " 用时：" + (System.currentTimeMillis() - s));

    }
}
